package cn.csdj.sism.web;

import cn.csdj.sism.pojo.Menu;
import cn.csdj.sism.pojo.MenuPermission;
import cn.csdj.sism.service.MenuPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@CrossOrigin
@Controller
@RequestMapping("/menuPermission")
public class MenuPermissionController {
    @Autowired
    private MenuPermissionService menuPermissionService;
    /**
     * 添加菜单权限
     * @param menuPermission
     * @return
     */
    @PostMapping
    public int Insert(@RequestBody MenuPermission menuPermission){
        return menuPermissionService.insert(menuPermission);
    }

    /**
     * 删除菜单权限
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public int deleteById(@PathVariable Integer id) {
        return menuPermissionService.deleteById(id);
    }
    /**
     * 修改菜单权限
     * @param menuPermission
     * @return
     */
    @PutMapping
    public int update(@RequestBody MenuPermission menuPermission){
        return menuPermissionService.update(menuPermission);
    }

    /**
     * 查询菜单权限
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public MenuPermission selectById(@PathVariable Integer id){
        return menuPermissionService.selectById(id);
    }
    /**
     * 查询全部菜单权限
     * @return
     */
    @GetMapping
    public List<MenuPermission> selectAll(){
        return menuPermissionService.selectAll();
    }
}
